package com.hellojavaweb.servlet;

import com.hellojavaweb.dao.UserDao;

import javax.servlet.ServletContext;
import java.io.IOException;
import java.sql.SQLException;

/**
 * Created by daitiantian on 2017/1/22.
 */
public class TradeOutServlet_dtt extends javax.servlet.http.HttpServlet {

    protected void doPost(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws javax.servlet.ServletException, IOException {
        double out;
        int id;
        String out1 = request.getParameter("out");
        out = Double.parseDouble(out1);

        String id1 = request.getParameter("id");
        id = Integer.parseInt(id1);

        UserDao userDao = new UserDao();
        int re = 0;
        try {
            re=userDao.zcDataBase(id,out);
        } catch (SQLException e) {
            e.printStackTrace();
        }
        if (re ==1)
        {
            ServletContext application = request.getServletContext();
            application.setAttribute("message", "支出成功!");
            response.sendRedirect("err_dtt.jsp");
        }




    }

    protected void doGet(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws javax.servlet.ServletException, IOException {

        doPost(request ,response);
    }
}